import getState from "@/api/state";
import ZuirealTimeData from "@/template/realTimeData/realTimeData";
import React from "react"
import { useEffect } from "react";
import { useState } from "react";

const ClmModule2 = ({ condition }) => {
    const [loading, setLoading] = useState(true);
    // 累计赔款数据
    const [repState, setRepState] = useState({
        title: "赔款",
        value: 0,
        unit:"万元",
        toFixed:true,
        childrenData: [
            {
                title: "全险种",
                value: 0
            },
            {
                title: "车险",
                value: 0
            },
            {
                title: "意健险",
                value: 0
            },
            {
                title: "财产险",
                value: 0
            },
        ]
    })
    // 赔款案件数量
    const [casState, setCasState] = useState({
        title: "赔款案件数量",
        value: 0,
        unit:"件",
        childrenData: [
            {
                title: "全险种",
                value: 0
            },
            {
                title: "车险",
                value: 0
            },
            {
                title: "意健险",
                value: 0
            },
            {
                title: "财产险",
                value: 0
            },
        ]
    },)
    // 拒赔客户数
    const [rejState, setRejState] = useState({
        title: "拒赔客户数",
        value: 0,
        unit:"人",
        childrenData: [
            {
                title: "全险种",
                value: 0
            },
            {
                title: "车险",
                value: 0
            },
            {
                title: "意健险",
                value: 0
            },
            {
                title: "财产险",
                value: 0
            },
        ]
    },)
    // 欺诈客户数 
    const [cheState, setCheState] = useState({
        title: "欺诈客户数",
        value: 0,
        unit:"人",
        childrenData: [
            {
                title: "全险种",
                value: 0
            },
            {
                title: "车险",
                value: 0
            },
            {
                title: "意健险",
                value: 0
            },
            {
                title: "财产险",
                value: 0
            },
        ]
    })
    // 全损案件数
    const [losState, setLosState] = useState({
        title: "全损案件数",
        value: 0,
        unit:"件",
        childrenData: [
            {
                title: "全险种",
                value: 0
            },
            {
                title: "车险",
                value: 0
            },
            {
                title: "意健险",
                value: 0
            },
            {
                title: "财产险",
                value: 0
            },
        ]
    })
    // 案均赔款
    const [avsState, setAvsState] = useState({
        title: "案均赔款",
        value: 0,
        unit:"万元",
        toFixed:true,//是否需要转换成2位小数
        childrenData: [
            {
                title: "全险种",
                value: 0
            },
            {
                title: "车险",
                value: 0
            },
            {
                title: "意健险",
                value: 0
            },
            {
                title: "财产险",
                value: 0
            },
        ]
    })


    // 获取数据
    useEffect(() => {
        // 获取累计赔款数据
        getState({
            apiUrl: "/cifgp-core-api/claim/monthAndYear",
            condition: { ...condition, cType: "clmreparation" },

            state: repState,
            setState: setRepState,
            setLoading,
        })
        // 获取赔款案件数量
        getState({
            apiUrl: "/cifgp-core-api/claim/monthAndYear",
            condition: { ...condition, cType: "clmcaseNum" },

            state: casState,
            setState: setCasState,
            setLoading,
        })
        // 获取拒赔客户数量
        getState({
            apiUrl: "/cifgp-core-api/claim/monthAndYear",
            condition: { ...condition, cType: "clmrejectNum" },

            state: rejState,
            setState: setRejState,
            setLoading,
        })
        // 获取欺诈客户数
        getState({
            apiUrl: "/cifgp-core-api/claim/monthAndYear",
            condition: { ...condition, cType: "clmcheatNum" },

            state: cheState,
            setState: setCheState,
            setLoading,
        })
        // 获取全损案件数
        getState({
            apiUrl: "/cifgp-core-api/claim/monthAndYear",
            condition: { ...condition, cType: "clmlossNum" },

            state: losState,
            setState: setLosState,
            setLoading,
        })
        // 获取案均赔款数
        getState({
            apiUrl: "/cifgp-core-api/claim/specialMonthAndYear",
            condition: { ...condition, cType: "clmavsCaseNum" },

            state: avsState,
            setState: setAvsState,
            setLoading,
        })
    }, [condition])



    return (
        <>
            <ZuirealTimeData
                loading={loading}
                style={{ width: "60%" }}
                title="赔付信息"
                hideBtn
                hideDownBtn
                transparent
                wrap
                itemStyle={{ width: "33.3333%" }}
                data={
                    [
                        repState, casState, rejState, cheState, losState, avsState
                    ]
                }
                
            />
        </>
    )
}
export default ClmModule2;